'use strict';
exports.main = async (event, context) => {
  const { species_id, is_liked } = event;
  const db = uniCloud.database();
  
  try {
    const result = await db.collection('species').doc(species_id).update({
      likes: db.command.inc(is_liked ? 1 : -1)
    });
    
    return {
      code: 200,
      message: '操作成功',
      data: result
    }
  } catch (error) {
    return {
      code: 500,
      message: error.message || '操作失败'
    }
  }
}; 